/*******************************************************************************
GFont.cpp

	Author:		LiuDingXi
	e-mail:		liudx@gmail.com
	Date time:	2009-08-26

	Copyright (C) 2009
	All rights reserved.
	
*******************************************************************************/
#include "StdAfx.h"
#include "GFont.h"

#if (_OS_ == _OS_WINNT_)
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
#endif//(_OS_ == _OS_WINNT_)

////////////////////////////////////////////////////////////////////////////////

GFont::GFont()
{
#if (_OS_ == _OS_WINNT_)

	m_hFont = NULL;
	memset(&m_lFont, 0, sizeof(m_lFont));
	
#elif(_OS_ == _OS_SYMBIAN_)
	
	m_pFont = NULL;
	memset(m_szFont, 0, sizeof(m_szFont));
	
#elif(_OS_ == _OS_IPHONE_)
	m_pFont = NULL;	
#endif

}

GFont::~GFont()
{
	Destroy();
}


#if (_OS_ == _OS_WINNT_)

bool GFont::Create(LPCTSTR szFont, LONG lHeight, LONG lWeight,
				   bool bItalic /* = false */, bool bUnderline /* = false */)
{
	Destroy();

	if(m_hFont == NULL)
	{
		_tcscpy(m_lFont.lfFaceName, szFont);
		m_lFont.lfHeight=lHeight;
		m_lFont.lfWeight=lWeight;
		m_lFont.lfItalic=bItalic;
		m_lFont.lfUnderline=bUnderline;
		m_hFont= ::CreateFontIndirect(&m_lFont);

		return (m_hFont != NULL) ? true : false;
	}
	return false;
}

bool GFont::Destroy()
{
	if(m_hFont)
	{
		::DeleteObject(m_hFont);
		m_hFont = NULL;
		return true;
	}
	return false;
}

#endif//(_OS_ == _OS_WINNT_)

#if (_OS_ == _OS_SYMBIAN_)


bool GFont::Create(LPCTSTR szFont, LONG lHeight, LONG lWeight,
				   bool bItalic /* = false */, bool bUnderline /* = false */)
{
	_tcscpy(m_szFont, szFont);
	m_lHeight = lHeight;
	m_lWeight = lWeight;
	m_bItalic = bItalic;
	m_bUnderline = bUnderline;
	return true;
}

bool GFont::Destroy()
{
	return false;
}

#endif//(_OS_ == _OS_SYMBIAN_)
